4<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="<%=request.getContextPath() %>/css/index3.css" rel="stylesheet">
</head>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">

	$(function(){
		$.post("getMap",{},function(map){
			//追加地址
			var list = map.list
			for(var i in list){
				$("[name=pid]").append("<option value='"+list[i].id+"'>"+list[i].cityname+"</option>")
			}
			//追加对选矿
			var list2 = map.list2
			for(var i in list2){
				$("#sp").append("<input type='checkbox' name='ids' value='"+list2[i].sid+"'> "+list2[i].sname+"")
			}
		},"json")
	})
	function addcityid(obj){
		$("[name=cityid] option:gt(0)").remove();
		$("[name=countiesid] option:gt(0)").remove();
		$.post("getCity",{pid:obj},function(list){
			//追加地址
			for(var i in list){
				$("[name=cityid]").append("<option value='"+list[i].id+"'>"+list[i].cityname+"</option>")
			}
			
		},"json")
	}
	function addcountiesod(obj){
		$("[name=countiesid] option:gt(0)").remove();
		$.post("getCity",{pid:obj},function(list){
			//追加地址
			for(var i in list){
				$("[name=countiesid]").append("<option value='"+list[i].id+"'>"+list[i].cityname+"</option>")
			}
			
		},"json")
	}
	function check(){
		//号码不能为空
		var cname1=$("[name=cname]").val();
		if (cname1==null || cname1 =="" ) {
			$("#reg1").html("用户名不能为空")
			return false;
		} else{
			$("#reg1").html("")
		}
		//号码不能为空
		var ctel1=$("[name=ctel]").val();
		if (ctel1 == null || ctel1 =="" ) {
			$("#reg2").html("电话号码不能为空")
			return false;
		} else{
			$("#reg2").html("")
		}
		//号码格式正确
		var tel = /^1[3-8]\d{9}$/
		if (!tel.test(ctel1)) {
			$("#reg2").html("号码格式不正确")
			return false;
		} else{
			$("#reg2").html("")
		}
	}
</script>
<body>
<center>
	<form action="add" method="post" onsubmit="return check()">
		用户姓名<input type="text" name="cname">
			<span id="reg1"></span>
		<br><br>
		用户电话<input type="text" name="ctel">
			<span id="reg2"></span>
		<br><br>
		是否是会员<input type="radio" name="cmemeber" value="1">是
				<input type="radio" name="cmemeber" value="0">否
				<br><br>
		地址<span id="sp">
			
		</span><br><br>
		<select name="pid" onchange="addcityid(this.value)">
			<option>---请选择省---</option>
		</select>
		<select name="cityid" onchange="addcountiesod(this.value)">
			<option>---请选择市---</option>
		</select>
		<select name="countiesid">
			<option>---请选择县---</option>
		</select><br><br>
		<input type="submit" value="提交">
	</form>
</center>




</body>
</html>